import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true },


  {
    path: '/venue-display',
    component: Layout,
    redirect: '/venue-display',
    meta: { title: '赛事管理', icon: 'el-icon-picture-outline' },
    children: [
      {
        path: '/venue-display',
        component: () => import('@/views/realTimeTraffic/venue-display/index'),
        meta: { title: '赛事板块管理', icon: 'el-icon-picture' }
      },
      {
        path: '/monitor-display',
        component: () => import('@/views/realTimeTraffic/monitor-display/index'),
        meta: { title: '赛事信息', icon: 'el-icon-camera-solid' }
      },
      {
        path: '/event-announcement',
        hidden:true,
        component: () => import('@/views/realTimeTraffic/event-announcement/index'),
        meta: { title: '赛事公告', icon: 'el-icon-camera-solid' }
      },
      {
        path: '/participating-teams',
        component: () => import('@/views/realTimeTraffic/participating-teams/index'),
        meta: { title: '队伍人员管理', icon: 'el-icon-camera-solid' }
      },
      {
        path: '/contest-notice',
        component:() => import('@/views/realTimeTraffic/contest-notice/index'),
        meta: {title:'公告管理', icon: 'el-icon-camera-solid'}
      },
      {
        path: '/user-info',
        component: () => import('@/views/realTimeTraffic/user-info/index'),
        // meta: {title: '用户信息', icon: 'el-icon-camera-solid'}
      }
    ]
  },
  //  用户路由
  {
    path: '/admin-background',
    component: Layout,
    redirect: 'admin-config',
    meta: { title: '用户', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'admin-config',
        component: () => import('@/views/admin-background/admin-config/index'),
        meta: { title: '主页', icon: 'el-icon-setting' }
      },
      {
        path: 'account-management',
        component: () => import('@/views/admin-background/account-management/index'),
        meta: { title: '赛事列表', icon: 'el-icon-user-solid' }
      },
      {
        path: 'updatePassword',
        hidden:true,
        component: () => import('@/views/admin-background/updatePassword/index'),
        meta: { title: '赛事详情', icon: 'el-icon-user' }
      },
      {
        path: 'myteam',
        component: () => import('@/views/admin-background/myteam/index'),
        meta: { title: '我的队伍', icon: 'el-icon-user' },
      },
      {
        path: 'teamNotice',
        hidden:true,
        component: () => import('@/views/admin-background/teamNotice/index'),
        meta: { title: '队伍公告', icon: 'el-icon-user' }
      },
      {
        path: 'view-event',
        hidden:true,
        component: () => import('@/views/admin-background/view-event/index'),
        meta: { title: '赛事公告', icon: 'el-icon-user' }
      },
      {
        path: 'user-info',
        component: () => import('@/views/realTimeTraffic/user-info/index'),
        meta: {title: '个人信息', icon: 'el-icon-camera-solid'}
      }
    ]
  }

]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
